#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <errno.h>
#include<unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include"Common.hpp"

int main()
{
    int outfd = open("abc.back",O_WRONLY | O_CREAT | O_TRUNC,0644);
    if(outfd<0) ERR_EXIT("open");

    int infd = open("tp",O_RDONLY);
    if(infd<0) ERR_EXIT("open");
    char buffer[1024];

    int n ;
    while((n = read(infd,buffer,sizeof(buffer)))>0)
    {
        write(outfd,buffer,n);
    }

    close(infd);
    close(outfd);

    unlink("tp");
    return 0;

}